<include file="__PUBLIC__/_header" />
<div class="navbar navbar-default" id="navbar">
    <script type="text/javascript">
        try{
            ace.settings.check('navbar' , 'fixed')}catch(e){

        }
    </script>
    <include file="__PUBLIC__/_header_title"/>
    <!-- /.container -->
</div>
<div class="main-container" id="main-container">
    <div class="main-container-inner">
        <a class="menu-toggler" id="menu-toggler" href="#"> <span class="menu-text"></span> </a>
        <div class="sidebar" id="sidebar">
            <include file="__PUBLIC__/_nav" />
            <!-- /.nav-list -->
            <div class="sidebar-collapse" id="sidebar-collapse">
                <i class="icon-double-angle-left" data-icon1="icon-double-angle-left" data-icon2="icon-double-angle-right"></i>
            </div>
        </div>
        <div class="main-content">
            <div class="breadcrumbs" id="breadcrumbs">
                <script type="text/javascript">
                    try{
                        ace.settings.check('breadcrumbs' , 'fixed')
                    }catch(e){
                    }
                </script>
                <ul class="breadcrumb">
                    <li> <i class="icon-home home-icon"></i> <a href="#">首页</a> </li>
                    <li class="active">系统管理</li>
                    <li class="active">设置</li>
                </ul>
                <!-- .breadcrumb -->
            </div>
            <div class="page-content">
                <div class="page-header">
                    <h1> 系统管理 <small> <i class="icon-double-angle-right"></i> 修改密码 </small> </h1>
                </div>
                <!-- /.page-header -->
                <div class="row">
                    <div class="col-xs-12">
                        <!-- PAGE CONTENT BEGINS -->
                        <div class="row">
                            <div class="col-xs-12">
                                <input type="hidden" name="m_id" id="m_id">
                                <form  method="post">
                                    <table id="data-table" class="table table-bordered table-hover definewidth m10" >
                                    <thead>
                                    <tr>
                                        <td colspan="13">密码管理</td>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <tr>
                                        <th width="10%">原密码</th>
                                        <td>
                                            <input id="oldPwd" max-length="50"  type="password"/>
                                        </td>
                                    </tr>
                                    <tr>
                                        <th width="10%">新密码</th>
                                        <td>
                                            <input id="newPwd" max-length="50" type="password"/>
                                        </td>
                                    </tr>
                                    <tr>
                                        <th width="10%">确认密码</th>
                                        <td>
                                            <input id="surePwd" max-length="50"  type="password"/>
                                        </td>
                                    </tr>

                                    </tbody>
                                    <tfoot>
                                    <tr>
                                        <td colspan="14">
                                            <div class="col-md-offset-4 col-md-9">
                                                <button class="btn btn-info" type="button" id="base_submit"> <i class="icon-ok bigger-110"></i> 确定 </button>
                                            </div>
                                       </td>
                                    </tr>
                                    </tfoot>
                                </table>
                                </form>
                            </div>
                            <!-- /span -->
                        </div>
                        <!-- /row -->
                    </div>
                    <!-- PAGE CONTENT ENDS -->
                </div>
                <!-- /.row -->
            </div>
        </div>
    </div>
</div>
<a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
    <i class="icon-double-angle-up icon-only bigger-110"></i>
</a>
<script src="__APP_SKIN__js/jquery-2.0.3.min.js"></script>
<script src="__APP_SKIN__js/bootstrap.min.js"></script>
<script>
    $(function(){

        $("#base_submit").click(function(){
            var   oldPwd=$.trim($('#oldPwd').val()),
                    newPwd=$.trim($('#newPwd').val()),
                    surePwd=$.trim($('#surePwd').val());

            if(oldPwd == ''){
                bootbox.dialog({
                    message: "<span class='btn-sm btn-danger'>请输入原密码！</span>"
                });
                return false;
            }
            if(newPwd == ''){
                bootbox.dialog({
                    message: "<span class='btn-sm btn-danger'>请输入新密码！</span>"
                });
                return false;
            }
            if (surePwd == '') {
                bootbox.dialog({
                    message: "<span class='btn-sm btn-danger'>请输入确认密码！</span>"
                });
                return false;
            }
            if (newPwd!= surePwd) {
                bootbox.dialog({
                    message: "<span class='btn-sm btn-danger'>新密码与确认密码不一致！</span>"
                });
                return false;
            }
            if (newPwd== oldPwd) {
                bootbox.dialog({
                    message: "<span class='btn-sm btn-danger'>新密码与原密码一致！</span>"
                });
                return false;
            }
            var data={"oldPwd":oldPwd, "newPwd":newPwd};
            $.ajax({
                type:"POST",
                async:false,
                dataType:"json",
                url:"{:Controller::createUrl('vis/profile/modifyPwd')}",
                data:data,
                success:function(data,textStatus){
                    if(data.code==200){
                        bootbox.dialog({
                            message: "<span class='bigger-110'>"+data.msg+"</span>",
                            buttons:
                            {
                                "success" :
                                {
                                    "label" : "<i class='icon-ok'></i> Success!",
                                    "className" : "btn-sm btn-success",
                                    "callback": function() {
                                        window.location.reload();
                                    }
                                }
                            }
                        });
                    }else{
                        bootbox.dialog({
                            message: "<span class='btn-sm btn-danger'>"+data.msg+"</span>"
                        });
                    }
                },
                error:function(XMLHttpRequest,textStatus,errorThrown){
                    bootbox.dialog({
                        message: "<span class='btn-sm btn-danger'>网络错误！</span>"
                    });

                }
            });
        })


    })
</script>
</body>

</html>